# @algorithm @lc id=2122 lang=python3 weekname=weekly-contest-257
# @title count-special-quadruplets


from cn.Python3.mod.preImport import *
# @test([1,2,3,6])=1
# @test([3,3,6,4,5])=0
# @test([1,1,1,3,5])=4
class Solution:
    def countQuadruplets(self, nums: List[int]) -> int:
        n = len(nums)
        ans = 0
        for i in range(n-3):
            for j in range(i+1, n-2):
                for k in range(j+1, n-1):
                    for l in range(k+1, n):
                        # print(i, j, k, l)
                        if nums[i]+nums[j] + nums[k] == nums[l]:
                            ans+=1
        return ans


# if __name__ == "__main__":
#     solution = Solution()
#     nums = 